<?php

class Application_Model_DbTable_PayCodeCard extends Application_Model_DbTable_DomainObject{
    
    protected $_name = 'uuch_paycode_cards';
    
    public function getMapper() {
        return array('id','cardNo','cardPwd','createTime','loseTime','mobile','typeid','state','cardType','money','userTime','userID');
    }
    
        
     public  function getFirstByType($type,$state){
            $db = $this->getAdapter();
            $filter = $db->quoteInto(' typeid = ?', $type);          
            $filter .= $db->quoteInto(' and state = ?', $state);   
            $rows = $this->fetchAll($filter,'id',1,0);
            
            $result = array();
            foreach ($rows as $row){
                array_push($result,$this->convertRowToObject($row));                    
            }           
            if($result)
                return $result[0];
            else
                return null;

        }
}